{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 一次性获取全部日k线数据\n",
    "\n",
    "#### 参数说明：\n",
    "\n",
    "> code：股票代码，即6位数字代码，或者指数代码（sh=上证指数 sz=深圳成指 hs300=沪深300指数 sz50=上证50 zxb=中小板 cyb=创业板）\n",
    "\n",
    "> start：开始日期，格式YYYY-MM-DD\n",
    "\n",
    "> end：结束日期，格式YYYY-MM-DD\n",
    "\n",
    "> ktype：数据类型，D=日k线 W=周 M=月 5=5分钟 15=15分钟 30=30分钟 60=60分钟，默认为D\n",
    "\n",
    "> retry_count：当网络异常后重试次数，默认为3\n",
    "\n",
    "> pause:重试时停顿秒数，默认为0\n",
    "#### 返回值说明：\n",
    "\n",
    "> date：日期\n",
    "\n",
    "> open：开盘价\n",
    "\n",
    "> high：最高价\n",
    "\n",
    "> close：收盘价\n",
    "\n",
    "> low：最低价\n",
    "\n",
    "> volume：成交量\n",
    "\n",
    "> price_change：价格变动\n",
    "\n",
    "> p_change：涨跌幅\n",
    "\n",
    "> ma5：5日均价\n",
    "\n",
    "> ma10：10日均价\n",
    "\n",
    "> ma20:20日均价\n",
    "\n",
    "> v_ma5:5日均量\n",
    "\n",
    "> v_ma10:10日均量\n",
    "\n",
    "> v_ma20:20日均量\n",
    "\n",
    "> turnover:换手率[注：指数无此项]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-11-27</th>\n",
       "      <td>29.65</td>\n",
       "      <td>31.11</td>\n",
       "      <td>31.11</td>\n",
       "      <td>29.64</td>\n",
       "      <td>1167366.75</td>\n",
       "      <td>1.50</td>\n",
       "      <td>5.07</td>\n",
       "      <td>30.050</td>\n",
       "      <td>29.112</td>\n",
       "      <td>28.127</td>\n",
       "      <td>730795.88</td>\n",
       "      <td>674953.91</td>\n",
       "      <td>719006.77</td>\n",
       "      <td>1.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-11-26</th>\n",
       "      <td>29.28</td>\n",
       "      <td>29.69</td>\n",
       "      <td>29.61</td>\n",
       "      <td>28.78</td>\n",
       "      <td>521332.16</td>\n",
       "      <td>0.29</td>\n",
       "      <td>0.99</td>\n",
       "      <td>29.612</td>\n",
       "      <td>28.817</td>\n",
       "      <td>27.869</td>\n",
       "      <td>657959.55</td>\n",
       "      <td>625697.91</td>\n",
       "      <td>700847.52</td>\n",
       "      <td>0.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-11-25</th>\n",
       "      <td>29.87</td>\n",
       "      <td>30.16</td>\n",
       "      <td>29.32</td>\n",
       "      <td>29.20</td>\n",
       "      <td>479353.34</td>\n",
       "      <td>-0.79</td>\n",
       "      <td>-2.62</td>\n",
       "      <td>29.268</td>\n",
       "      <td>28.726</td>\n",
       "      <td>27.694</td>\n",
       "      <td>648458.91</td>\n",
       "      <td>645424.17</td>\n",
       "      <td>704963.38</td>\n",
       "      <td>0.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-11-24</th>\n",
       "      <td>29.75</td>\n",
       "      <td>30.17</td>\n",
       "      <td>30.11</td>\n",
       "      <td>29.60</td>\n",
       "      <td>510406.44</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.03</td>\n",
       "      <td>28.904</td>\n",
       "      <td>28.625</td>\n",
       "      <td>27.495</td>\n",
       "      <td>683619.45</td>\n",
       "      <td>699026.21</td>\n",
       "      <td>705514.68</td>\n",
       "      <td>0.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-11-23</th>\n",
       "      <td>29.08</td>\n",
       "      <td>30.58</td>\n",
       "      <td>30.10</td>\n",
       "      <td>29.08</td>\n",
       "      <td>975520.69</td>\n",
       "      <td>1.18</td>\n",
       "      <td>4.08</td>\n",
       "      <td>28.534</td>\n",
       "      <td>28.346</td>\n",
       "      <td>27.256</td>\n",
       "      <td>696789.86</td>\n",
       "      <td>703867.94</td>\n",
       "      <td>708158.93</td>\n",
       "      <td>1.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-06-05</th>\n",
       "      <td>8.16</td>\n",
       "      <td>8.26</td>\n",
       "      <td>8.17</td>\n",
       "      <td>8.04</td>\n",
       "      <td>620818.06</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.12</td>\n",
       "      <td>8.112</td>\n",
       "      <td>8.112</td>\n",
       "      <td>8.112</td>\n",
       "      <td>630931.16</td>\n",
       "      <td>630931.16</td>\n",
       "      <td>630931.16</td>\n",
       "      <td>0.81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-06-04</th>\n",
       "      <td>8.12</td>\n",
       "      <td>8.19</td>\n",
       "      <td>8.16</td>\n",
       "      <td>8.07</td>\n",
       "      <td>535722.06</td>\n",
       "      <td>0.04</td>\n",
       "      <td>0.49</td>\n",
       "      <td>8.098</td>\n",
       "      <td>8.098</td>\n",
       "      <td>8.098</td>\n",
       "      <td>633459.44</td>\n",
       "      <td>633459.44</td>\n",
       "      <td>633459.44</td>\n",
       "      <td>0.70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-06-01</th>\n",
       "      <td>8.05</td>\n",
       "      <td>8.27</td>\n",
       "      <td>8.11</td>\n",
       "      <td>7.92</td>\n",
       "      <td>644328.12</td>\n",
       "      <td>0.02</td>\n",
       "      <td>0.25</td>\n",
       "      <td>8.077</td>\n",
       "      <td>8.077</td>\n",
       "      <td>8.077</td>\n",
       "      <td>666038.56</td>\n",
       "      <td>666038.56</td>\n",
       "      <td>666038.56</td>\n",
       "      <td>0.84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-05-31</th>\n",
       "      <td>8.06</td>\n",
       "      <td>8.11</td>\n",
       "      <td>8.09</td>\n",
       "      <td>7.95</td>\n",
       "      <td>644046.69</td>\n",
       "      <td>0.07</td>\n",
       "      <td>0.87</td>\n",
       "      <td>8.060</td>\n",
       "      <td>8.060</td>\n",
       "      <td>8.060</td>\n",
       "      <td>676893.79</td>\n",
       "      <td>676893.79</td>\n",
       "      <td>676893.79</td>\n",
       "      <td>0.84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-05-30</th>\n",
       "      <td>8.30</td>\n",
       "      <td>8.30</td>\n",
       "      <td>8.03</td>\n",
       "      <td>7.95</td>\n",
       "      <td>709740.88</td>\n",
       "      <td>-0.33</td>\n",
       "      <td>-3.95</td>\n",
       "      <td>8.030</td>\n",
       "      <td>8.030</td>\n",
       "      <td>8.030</td>\n",
       "      <td>709740.88</td>\n",
       "      <td>709740.88</td>\n",
       "      <td>709740.88</td>\n",
       "      <td>0.93</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>609 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low      volume  price_change  p_change  \\\n",
       "date                                                                         \n",
       "2020-11-27  29.65  31.11  31.11  29.64  1167366.75          1.50      5.07   \n",
       "2020-11-26  29.28  29.69  29.61  28.78   521332.16          0.29      0.99   \n",
       "2020-11-25  29.87  30.16  29.32  29.20   479353.34         -0.79     -2.62   \n",
       "2020-11-24  29.75  30.17  30.11  29.60   510406.44          0.01      0.03   \n",
       "2020-11-23  29.08  30.58  30.10  29.08   975520.69          1.18      4.08   \n",
       "...           ...    ...    ...    ...         ...           ...       ...   \n",
       "2018-06-05   8.16   8.26   8.17   8.04   620818.06          0.01      0.12   \n",
       "2018-06-04   8.12   8.19   8.16   8.07   535722.06          0.04      0.49   \n",
       "2018-06-01   8.05   8.27   8.11   7.92   644328.12          0.02      0.25   \n",
       "2018-05-31   8.06   8.11   8.09   7.95   644046.69          0.07      0.87   \n",
       "2018-05-30   8.30   8.30   8.03   7.95   709740.88         -0.33     -3.95   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "date                                                                           \n",
       "2020-11-27  30.050  29.112  28.127  730795.88  674953.91  719006.77      1.38  \n",
       "2020-11-26  29.612  28.817  27.869  657959.55  625697.91  700847.52      0.62  \n",
       "2020-11-25  29.268  28.726  27.694  648458.91  645424.17  704963.38      0.57  \n",
       "2020-11-24  28.904  28.625  27.495  683619.45  699026.21  705514.68      0.60  \n",
       "2020-11-23  28.534  28.346  27.256  696789.86  703867.94  708158.93      1.15  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2018-06-05   8.112   8.112   8.112  630931.16  630931.16  630931.16      0.81  \n",
       "2018-06-04   8.098   8.098   8.098  633459.44  633459.44  633459.44      0.70  \n",
       "2018-06-01   8.077   8.077   8.077  666038.56  666038.56  666038.56      0.84  \n",
       "2018-05-31   8.060   8.060   8.060  676893.79  676893.79  676893.79      0.84  \n",
       "2018-05-30   8.030   8.030   8.030  709740.88  709740.88  709740.88      0.93  \n",
       "\n",
       "[609 rows x 14 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import tushare as ts\n",
    "\n",
    "ts.get_hist_data('600031')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 设定历史数据的时间："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-11-27</th>\n",
       "      <td>21.42</td>\n",
       "      <td>22.22</td>\n",
       "      <td>21.92</td>\n",
       "      <td>21.41</td>\n",
       "      <td>64560.53</td>\n",
       "      <td>0.5</td>\n",
       "      <td>2.33</td>\n",
       "      <td>21.73</td>\n",
       "      <td>21.894</td>\n",
       "      <td>22.453</td>\n",
       "      <td>43939.32</td>\n",
       "      <td>43028.23</td>\n",
       "      <td>84445.88</td>\n",
       "      <td>0.62</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low    volume  price_change  p_change  \\\n",
       "date                                                                       \n",
       "2020-11-27  21.42  22.22  21.92  21.41  64560.53           0.5      2.33   \n",
       "\n",
       "              ma5    ma10    ma20     v_ma5    v_ma10    v_ma20  turnover  \n",
       "date                                                                       \n",
       "2020-11-27  21.73  21.894  22.453  43939.32  43028.23  84445.88      0.62  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.get_hist_data('600848',start='2020-11-27',end='2020-11-29')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 其他："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n",
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n",
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n",
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n",
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n",
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n",
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n",
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n",
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n",
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n",
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n",
      "本接口即将停止更新，请尽快使用Pro版接口：https://waditu.com/document/2\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-11-27</th>\n",
       "      <td>2614.66</td>\n",
       "      <td>2635.69</td>\n",
       "      <td>2618.99</td>\n",
       "      <td>2594.07</td>\n",
       "      <td>15120457.0</td>\n",
       "      <td>9.60</td>\n",
       "      <td>0.37</td>\n",
       "      <td>2641.014</td>\n",
       "      <td>2650.849</td>\n",
       "      <td>2695.438</td>\n",
       "      <td>16994841.40</td>\n",
       "      <td>16801810.20</td>\n",
       "      <td>18925399.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-11-26</th>\n",
       "      <td>2616.74</td>\n",
       "      <td>2632.87</td>\n",
       "      <td>2609.39</td>\n",
       "      <td>2584.69</td>\n",
       "      <td>15229393.0</td>\n",
       "      <td>-6.14</td>\n",
       "      <td>-0.23</td>\n",
       "      <td>2650.634</td>\n",
       "      <td>2659.631</td>\n",
       "      <td>2697.281</td>\n",
       "      <td>17001972.20</td>\n",
       "      <td>16859007.60</td>\n",
       "      <td>19357890.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-11-25</th>\n",
       "      <td>2678.11</td>\n",
       "      <td>2679.03</td>\n",
       "      <td>2615.53</td>\n",
       "      <td>2615.53</td>\n",
       "      <td>18225680.0</td>\n",
       "      <td>-59.27</td>\n",
       "      <td>-2.22</td>\n",
       "      <td>2657.788</td>\n",
       "      <td>2668.743</td>\n",
       "      <td>2701.808</td>\n",
       "      <td>17201388.40</td>\n",
       "      <td>16985978.60</td>\n",
       "      <td>19704948.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-11-24</th>\n",
       "      <td>2689.80</td>\n",
       "      <td>2700.02</td>\n",
       "      <td>2674.80</td>\n",
       "      <td>2664.95</td>\n",
       "      <td>16257889.0</td>\n",
       "      <td>-11.56</td>\n",
       "      <td>-0.43</td>\n",
       "      <td>2658.816</td>\n",
       "      <td>2675.342</td>\n",
       "      <td>2704.555</td>\n",
       "      <td>16941776.80</td>\n",
       "      <td>17205251.80</td>\n",
       "      <td>19807822.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-11-23</th>\n",
       "      <td>2677.35</td>\n",
       "      <td>2705.77</td>\n",
       "      <td>2686.36</td>\n",
       "      <td>2653.08</td>\n",
       "      <td>20140788.0</td>\n",
       "      <td>19.27</td>\n",
       "      <td>0.72</td>\n",
       "      <td>2655.474</td>\n",
       "      <td>2685.184</td>\n",
       "      <td>2703.353</td>\n",
       "      <td>17406547.00</td>\n",
       "      <td>18164339.10</td>\n",
       "      <td>19838000.35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-06-05</th>\n",
       "      <td>1702.37</td>\n",
       "      <td>1747.75</td>\n",
       "      <td>1746.11</td>\n",
       "      <td>1702.37</td>\n",
       "      <td>13695946.0</td>\n",
       "      <td>43.18</td>\n",
       "      <td>2.54</td>\n",
       "      <td>1725.710</td>\n",
       "      <td>1725.710</td>\n",
       "      <td>1725.710</td>\n",
       "      <td>13790605.80</td>\n",
       "      <td>13790605.80</td>\n",
       "      <td>13790605.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-06-04</th>\n",
       "      <td>1709.57</td>\n",
       "      <td>1715.41</td>\n",
       "      <td>1702.93</td>\n",
       "      <td>1690.99</td>\n",
       "      <td>12355914.0</td>\n",
       "      <td>-6.62</td>\n",
       "      <td>-0.39</td>\n",
       "      <td>1720.610</td>\n",
       "      <td>1720.610</td>\n",
       "      <td>1720.610</td>\n",
       "      <td>13814270.75</td>\n",
       "      <td>13814270.75</td>\n",
       "      <td>13814270.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-06-01</th>\n",
       "      <td>1734.35</td>\n",
       "      <td>1744.01</td>\n",
       "      <td>1709.55</td>\n",
       "      <td>1699.68</td>\n",
       "      <td>12174330.0</td>\n",
       "      <td>-34.19</td>\n",
       "      <td>-1.96</td>\n",
       "      <td>1726.503</td>\n",
       "      <td>1726.503</td>\n",
       "      <td>1726.503</td>\n",
       "      <td>14300389.67</td>\n",
       "      <td>14300389.67</td>\n",
       "      <td>14300389.67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-05-31</th>\n",
       "      <td>1741.33</td>\n",
       "      <td>1748.53</td>\n",
       "      <td>1743.74</td>\n",
       "      <td>1714.85</td>\n",
       "      <td>14120851.0</td>\n",
       "      <td>17.52</td>\n",
       "      <td>1.01</td>\n",
       "      <td>1734.980</td>\n",
       "      <td>1734.980</td>\n",
       "      <td>1734.980</td>\n",
       "      <td>15363419.50</td>\n",
       "      <td>15363419.50</td>\n",
       "      <td>15363419.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-05-30</th>\n",
       "      <td>1744.24</td>\n",
       "      <td>1758.87</td>\n",
       "      <td>1726.22</td>\n",
       "      <td>1724.28</td>\n",
       "      <td>16605988.0</td>\n",
       "      <td>-47.43</td>\n",
       "      <td>-2.67</td>\n",
       "      <td>1726.220</td>\n",
       "      <td>1726.220</td>\n",
       "      <td>1726.220</td>\n",
       "      <td>16605988.00</td>\n",
       "      <td>16605988.00</td>\n",
       "      <td>16605988.00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>610 rows × 13 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "               open     high    close      low      volume  price_change  \\\n",
       "date                                                                       \n",
       "2020-11-27  2614.66  2635.69  2618.99  2594.07  15120457.0          9.60   \n",
       "2020-11-26  2616.74  2632.87  2609.39  2584.69  15229393.0         -6.14   \n",
       "2020-11-25  2678.11  2679.03  2615.53  2615.53  18225680.0        -59.27   \n",
       "2020-11-24  2689.80  2700.02  2674.80  2664.95  16257889.0        -11.56   \n",
       "2020-11-23  2677.35  2705.77  2686.36  2653.08  20140788.0         19.27   \n",
       "...             ...      ...      ...      ...         ...           ...   \n",
       "2018-06-05  1702.37  1747.75  1746.11  1702.37  13695946.0         43.18   \n",
       "2018-06-04  1709.57  1715.41  1702.93  1690.99  12355914.0         -6.62   \n",
       "2018-06-01  1734.35  1744.01  1709.55  1699.68  12174330.0        -34.19   \n",
       "2018-05-31  1741.33  1748.53  1743.74  1714.85  14120851.0         17.52   \n",
       "2018-05-30  1744.24  1758.87  1726.22  1724.28  16605988.0        -47.43   \n",
       "\n",
       "            p_change       ma5      ma10      ma20        v_ma5       v_ma10  \\\n",
       "date                                                                           \n",
       "2020-11-27      0.37  2641.014  2650.849  2695.438  16994841.40  16801810.20   \n",
       "2020-11-26     -0.23  2650.634  2659.631  2697.281  17001972.20  16859007.60   \n",
       "2020-11-25     -2.22  2657.788  2668.743  2701.808  17201388.40  16985978.60   \n",
       "2020-11-24     -0.43  2658.816  2675.342  2704.555  16941776.80  17205251.80   \n",
       "2020-11-23      0.72  2655.474  2685.184  2703.353  17406547.00  18164339.10   \n",
       "...              ...       ...       ...       ...          ...          ...   \n",
       "2018-06-05      2.54  1725.710  1725.710  1725.710  13790605.80  13790605.80   \n",
       "2018-06-04     -0.39  1720.610  1720.610  1720.610  13814270.75  13814270.75   \n",
       "2018-06-01     -1.96  1726.503  1726.503  1726.503  14300389.67  14300389.67   \n",
       "2018-05-31      1.01  1734.980  1734.980  1734.980  15363419.50  15363419.50   \n",
       "2018-05-30     -2.67  1726.220  1726.220  1726.220  16605988.00  16605988.00   \n",
       "\n",
       "                 v_ma20  \n",
       "date                     \n",
       "2020-11-27  18925399.30  \n",
       "2020-11-26  19357890.15  \n",
       "2020-11-25  19704948.90  \n",
       "2020-11-24  19807822.60  \n",
       "2020-11-23  19838000.35  \n",
       "...                 ...  \n",
       "2018-06-05  13790605.80  \n",
       "2018-06-04  13814270.75  \n",
       "2018-06-01  14300389.67  \n",
       "2018-05-31  15363419.50  \n",
       "2018-05-30  16605988.00  \n",
       "\n",
       "[610 rows x 13 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ts.get_hist_data('600848', ktype='W')\n",
    "ts.get_hist_data('600848', ktype='M')\n",
    "ts.get_hist_data('600848', ktype='5')\n",
    "ts.get_hist_data('600848', ktype='15')\n",
    "ts.get_hist_data('600848', ktype='30')\n",
    "ts.get_hist_data('600848', ktype='60')\n",
    "ts.get_hist_data('sh')\n",
    "ts.get_hist_data('sz')\n",
    "ts.get_hist_data('hs300')\n",
    "ts.get_hist_data('sz50')\n",
    "ts.get_hist_data('zxb')\n",
    "ts.get_hist_data('cyb')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 大盘指数行情列表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "      code    name  change        open    preclose       close        high  \\\n",
      "0   000001    上证指数    1.14   3373.8434   3369.7334   3408.3071   3408.3071   \n",
      "1   000002    Ａ股指数    1.15   3536.2357   3531.9138   3572.4430   3572.4430   \n",
      "2   000003    Ｂ股指数   -0.53    245.7015    245.9900    244.6760    246.2201   \n",
      "3   000008    综合指数    2.06   3024.0003   3016.8584   3078.9342   3078.9342   \n",
      "4   000009   上证380    0.15   5751.4472   5750.8494   5759.1952   5759.2007   \n",
      "5   000010   上证180    1.41  10142.8352  10124.5743  10267.6132  10267.6132   \n",
      "6   000011    基金指数    0.81   7260.2823   7261.2802   7319.8450   7321.5667   \n",
      "7   000012    国债指数    0.03    183.0364    183.0198    183.0678    183.0678   \n",
      "8   000016    上证50    1.54   3453.3086   3445.7388   3498.6589   3498.6589   \n",
      "9   000017     新综指    1.15   2851.3748   2847.8878   2880.5785   2880.5785   \n",
      "10  000300   沪深300    1.24   4930.5928   4919.5912   4980.7650   4980.7650   \n",
      "11  000905   中证500    0.27   6337.3839   6334.3042   6351.6119   6351.8103   \n",
      "12  399001    深证成指    0.67  13627.8550  13599.9940  13690.8840  13690.8840   \n",
      "13  399002    深成指R    0.67  16915.6150  16881.0310  16993.8480  16993.8480   \n",
      "14  399003    成份Ｂ指    2.14   6513.7790   6502.4430   6641.6870   6650.4990   \n",
      "15  399004  深证100R    0.98   8294.4640   8266.5870   8347.4840   8347.4840   \n",
      "16  399005    中小板指    0.96   8966.4960   8942.4840   9028.1940   9028.1940   \n",
      "17  399006    创业板指    0.37   2614.6640   2609.3860   2618.9910   2635.6940   \n",
      "18  399008   中小300    0.68   1662.5180   1659.6520   1670.9730   1670.9730   \n",
      "19  399100   新 指 数    0.46  10263.3690  10249.0630  10295.8200  10295.8200   \n",
      "20  399101    中小板综    0.55  12416.1670  12398.4760  12466.5890  12466.5890   \n",
      "21  399106    深证综指    0.34   2247.9630   2245.4710   2253.1200   2253.1200   \n",
      "22  399107    深证Ａ指    0.34   2352.5270   2349.9180   2357.8770   2357.8770   \n",
      "23  399108    深证Ｂ指    1.62   1010.1460   1009.0440   1025.4160   1025.4160   \n",
      "24  399333    中小板R    0.96  10183.4510  10156.1800  10253.5230  10253.5230   \n",
      "25  399606    创业板R    0.37   2775.5210   2769.9190   2780.1150   2797.8450   \n",
      "\n",
      "           low       volume     amount  \n",
      "0    3364.4919    280649894  3260.6955  \n",
      "1    3526.4743    280180247  3252.6906  \n",
      "2     243.1087       383116     1.6806  \n",
      "3    3016.9936     72543728   717.9124  \n",
      "4    5699.4706     52413949   605.9543  \n",
      "5   10127.2038    110221663  1467.8677  \n",
      "6    7254.0521    122777328   484.1700  \n",
      "7     182.9907        80107     0.7421  \n",
      "8    3447.6084     53901248   782.4924  \n",
      "9    2843.5091    263715175  2929.5154  \n",
      "10   4917.3479    162952922  2531.7897  \n",
      "11   6276.0729    120885116  1174.0796  \n",
      "12  13542.6770  30965615119  3996.5238  \n",
      "13  16809.8850  12882377099  2075.1087  \n",
      "14   6498.1400     29557301     1.8474  \n",
      "15   8256.5910   3945960708  1023.9309  \n",
      "16   8917.5080  12107148685  1467.8992  \n",
      "17   2594.0680   9244513385  1609.3712  \n",
      "18   1652.0850   6246945787   982.5280  \n",
      "19  10190.7130  29715466674  3915.9792  \n",
      "20  12332.2940  12107148685  1467.8992  \n",
      "21   2231.2310  30965615119  3996.5238  \n",
      "22   2334.9670  30922653975  3994.2393  \n",
      "23   1008.6410     42961144     2.2845  \n",
      "24  10127.8130   2724634991   626.7258  \n",
      "25   2753.6590   1512045739   433.6181  \n"
     ]
    }
   ],
   "source": [
    "import tushare as ts\n",
    "\n",
    "df = ts.get_index()\n",
    "print(df)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 返回值说明：\n",
    "\n",
    "##### code:指数代码\n",
    "##### name:指数名称\n",
    "##### change:涨跌幅\n",
    "##### open:开盘点位\n",
    "##### preclose:昨日收盘点位\n",
    "##### close:收盘点位\n",
    "##### high:最高点位\n",
    "##### low:最低点位\n",
    "##### volume:成交量(手)\n",
    "##### amount:成交金额（亿元）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
